﻿using System.Windows.Forms;

namespace Nextensions.GUI.Controls
{
    public class DragDropTextBox: TextBox
    {
        protected override void OnDragEnter(DragEventArgs drgevent)
        {
            base.OnDragEnter(drgevent);

            if (drgevent.Data.GetDataPresent(DataFormats.FileDrop))
                drgevent.Effect = DragDropEffects.All;
            else
                drgevent.Effect = DragDropEffects.None;
        }

        protected override void OnDragDrop(DragEventArgs drgevent)
        {
            base.OnDragDrop(drgevent);

            Text = ((string[])drgevent.Data.GetData(DataFormats.FileDrop, false))[0];
        }

        public override bool AllowDrop
        {
            get
            {
                return true;
            }
            set
            {
            }
        }
    }
}
